# -*- coding: utf-8 -*-
##############################################################################
#
#    OpenERP, Open Source Management Solution
#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU Affero General Public License as
#    published by the Free Software Foundation, either version 3 of the
#    License, or (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Affero General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

from openerp.osv import fields, osv
from openerp.tools.translate import _


class crea8s_exer2_class(osv.osv):
    _name = "crea8s.exer2.class"
    _description = "exer2.class-crea8s_t1"
    _columns = {

        'name': fields.char('Name', size=50),
        'customer': fields.many2one('res.partner', 'Customer'),
        'customer_ref': fields.char('Customer Reference', size=50),
        'date': fields.datetime('Date...+Time'),
        'amount_untaxed': fields.float('Untaxed Amount',digits=(3,2)),
        'amount_taxes': fields.float('Taxes', digits=(3,2)),
        'amount_total': fields.float('Total', digits=(3,2)),
        'note': fields.text('Terms and conditions'), 
#         'state': fields.char('State', size=50),
        'state' : fields.selection([('draft', 'Draft'), ('confirmed', 'Confirmed'), ('done', 'Done')], 'State'),
        'details': fields.one2many('exer2.detail', 'exer2_parent_id', 'Details'), 
        
        'estimate_no': fields.char('Estimate No', size=64), 
        'address': fields.char('Address', size=128), # +read only ; +from partner
        
        #??? is_company === TRUE 
        'vehicle_no': fields.char ('Vehicle No', size=128), 
        'make_model': fields.char ('Make/Model', size=128), #
        'chassis_eng': fields.char('Chassis / English', size=128), #
        
        'accident_date': fields.date('Accident Date'), # read only ; state not in DRAFT.
        'claim_no': fields.char('Claim No', size=64), #
        'policy_no': fields.char('Policy No', size=64), #
        
        
        'pricelist_id': fields.many2one('product.pricelist', 'Pricelist', required=False, readonly=False, help="Pricelist for current sales order."),
        'currency_id': fields.related('pricelist_id', 'currency_id', type="many2one", relation="res.currency", string="Currency", readonly=False, required=False),

        
                'name1': fields.char('Name1', size=50),
                'name2': fields.char('Name2', size=50),
                'name3': fields.char('Name3', size=50),
                'name4': fields.char('Name4', size=50),
    }
#     _defaults = {
#         'pricelist_id': lambda s, cr, uid, c: s.pool.get('product.pricelist').price_get(cr, uid, 'crea8s.exer2.class', context=c),
#     }
    strFormatTime = '%Y-%m-%d %H-%M-%S %Z'
    
    # <button ...type="object"
    def B2_2_TinhDienTichHinhChuNhata(self, cr, uid, ids, context={}): 
        print 'crea8s_exer2_class: alert....'
        return True
    
    
    #   
class exer2_detail(osv.osv):
    _name = 'exer2.detail'
    _description = 'exer2.detail...'
    _columns = {
    
        'exer2_parent_id': fields.many2one('crea8s.exer2.class', 'exer2_parent_id...'),

        'line_no' : fields.integer('LineNo'),
        'product' : fields.char('Product', size=50),
        'description' : fields.char('Description', size=50),
        'qty' : fields.float('Quantity', digits=(3,2)),
        'tax' : fields.float('Tax', digits=(3,2)),
        'unit_price' : fields.float('Unit Price', digits=(3,2)),
        'sub_total' : fields.float('Subtotal', digits=(3,2)),
        
                
    }

crea8s_exer2_class()


